﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Traceability.API.Applications.Command.PictureCommand;
using Traceability.Domain.DTO.Output;
using Traceability.ErrorCode;

namespace Traceability.API.Controllers
{
    /// <summary>
    /// 图片控制器——API
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PictureController : ControllerBase
    {
        private readonly IMediator mediator;

        public PictureController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 图片添加
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> PictureAdd(PictureAddCommand command)
        {
            return await mediator.Send(command);
        }


        /// <summary>
        /// 图片显示
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<APIResult<List<PictureOutput>>> PictureGet([FromQuery]PictureQueryCommand command)
        {
            return  mediator.Send(command);
        }


        /// <summary>
        /// 图片删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> PictureDel([FromQuery]PictureDelCommand command)
        {
            return await mediator.Send(command);
        }
    }

}
